package com.epfresh.adapter;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebChromeClient;
import android.webkit.WebResourceRequest;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.epfresh.R;
import com.epfresh.bean.AdBean;

import multitype.ItemViewBinder;

/**
 * Author: Chen
 * Date: 2019/4/3
 * Desc:
 */
public class AdViewBinder extends ItemViewBinder<AdBean,AdViewBinder.ViewHolder> {

    @NonNull
    @Override
    protected ViewHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
        View itemView = inflater.inflate(R.layout.item_ad,parent,false);
        return new ViewHolder(itemView);
    }

    @Override
    protected void onBindViewHolder(@NonNull ViewHolder holder, @NonNull AdBean item) {

        holder.wv.loadUrl("https://www.baidu.com/");
        holder.wv.setFocusable(false);
        holder.wv.setFocusableInTouchMode(false);
        WebSettings webSettings = holder.wv.getSettings();
        webSettings.setDomStorageEnabled(true);
        holder.wv.setWebViewClient(new WebViewClient(){
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                return super.shouldOverrideUrlLoading(view, url);
            }
        });
    }

    static class ViewHolder extends RecyclerView.ViewHolder {
        private WebView wv;

        ViewHolder(View itemView) {
            super(itemView);
            wv = itemView.findViewById(R.id.wv);
        }
    }



}
